package com.hzm.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hzm.dao.TeacherDao;
import com.hzm.entity.Teacher;
import com.hzm.service.TeacherService;
import com.hzm.utils.Result;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @program: qy137-java
 * @description:
 * @author: 皇子明
 * @create: 2021-10-22 10:44
 **/
@Service
public class TeacherServiceImpl extends ServiceImpl<TeacherDao,Teacher> implements TeacherService  {
    @Resource
    private TeacherDao teacherDao;
    @Override
    public Result queryAllTeacherBYTeacherName(String teacherName) {
        Teacher teacher= teacherDao.queryAllTeacherBYTeacherName(teacherName);
        Result result = new Result(2000, "成功", teacher);
        return result;
    }

    @Override
    public Result findTeacherBYMobile(String mobile) {
        QueryWrapper<Teacher> wrapper = new QueryWrapper<>();
        wrapper.eq("mobile",mobile);
        Teacher teacher = teacherDao.selectOne(wrapper);
        Result result = new Result(2000, "获取成功", teacher);
        return result;
    }

    @Override
    public Result updateTeacherBYMobile(Teacher teacher) {
        int i=teacherDao.updateById(teacher);
        if (i>0){
            return new Result(2000,"修改成功",null);
        }else {
            return new Result(5000,"修改失败",null);
        }
    }


}
